package org.springframework.beans.util;

import org.springframework.beans.BeansException;

import java.lang.reflect.Field;

/**
 * @author xiaohei
 */
public class BeanUtil {

    public static void setFieldValue(Object obj, String name, Object value) {
        try {
            Field field = ClassUtil.getFiled(obj, name);
            if (field.getType() == String.class) {
                field.setAccessible(true);
                field.set(obj, value);
            }
        } catch (Exception  e) {
            throw new BeansException("failed instance bean");
        }
    }


}
